let router = require('../router/Router');
let payAcctService = require('../service/payAcctService');

const { BusiError, SysError } = require('../exception/exception');


router.post("/auth/pay/acct", function (req, resp) {
    payAcctService.getAcct(req.uid).then(res => {
        resp.send({code: 200, msg: "success", data: res});
    }).catch(e => {
        console.logw("err:", e);
        resp.send({code: 500, msg: e});
    });
});

router.post("/auth/pay/acct/alter/alipay", function (req, resp) {
    payAcctService.alter({uid: req.uid, acct: req.body.acct, realName: req.body.realName, type: 'A0000'}).then(res => {
        if (res > 0) {
            resp.send({code: 200, msg: "success", data: req.body.acct});
        } else {
            resp.send({code: 500, msg: "操作失败"});
        }
    }).catch(e => {
        console.logw("err:", e);
        resp.send({code: 500, msg: e});
    });
});

router.post("/auth/pay/acct/alter/bankCard", function (req, resp) {
    payAcctService.alter({uid: req.uid, acct: req.body.acct, realName: req.body.realName, type: 'B0000'}).then(res => {
        if (res > 0) {
            resp.send({code: 200, msg: "success", data: req.body.acct});
        } else {
            resp.send({code: 500, msg: "操作失败"});
        }
    }).catch(e => {
        console.logw("err:", e);
        resp.send({code: 500, msg: e});
    });
});
